﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Liya.Crm.Web.Models;
using Liya.Crm.Utility;
using System.Web.Security;

namespace Liya.Crm.Web.Controllers
{
    public class BaseController : Controller
    {
        //private static readonly string Key_UserData;

        static BaseController()
        {
            //Key_UserData = EncryptHelper.GetMD5("LoginUserData");
        }

        public UserData LoginUser{
            get {
                return GetUserData();
            }
        }

        private UserData GetUserData()
        {
            string val = CookieHelper.GetValue(FormsAuthentication.FormsCookieName);
            FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(val);//解密

            return JsonHelper.JsonDeserialize<UserData>(authTicket.UserData);
        }
    }
}
